﻿///// AnnotatedImages /////

using System;
using System.Collections.Generic;
using System.Collections;
//using System.Linq;
using System.Text;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace AnnotatedImages
{
    class Program
    {
        static void Main(string[] args)
        {
            // Creates a PDF file with an annotated image.
            // 
            // @param args:  no arguments needed here

            Console.WriteLine("Chapter 15: example AnnotatedImages");
            Console.WriteLine("-> Creates a PDF with annotated images;");
            Console.WriteLine("-> resources needed: foxdog.jpg (chapter 5) and iTextLogo.gif (chapter 10)");
            Console.WriteLine("-> file generated:");
            Console.WriteLine("   annotated_images.pdf");
            // step 1: creation of a document-object
            Document document = new Document(PageSize.A4, 50, 50, 50, 50);
            try
            {
                // step 2:
                // we create a writer that listens to the document
                PdfWriter.GetInstance(document, new FileStream("annotated_images.pdf", FileMode.Create));
                // step 3: we open the document
                document.Open();
                // step 4: we add some content
                Image gif = Image.GetInstance(@"D:\Temp\DD.jpg");
                gif.Annotation = new Annotation(0, 0, 0, 0, "http://www.lowagie.com/iText");
                gif.SetAbsolutePosition(30f, 750f);
                document.Add(gif);
                Image jpeg = Image.GetInstance(@"Store.jpg");
                jpeg.Annotation = new Annotation("picture", "quick brown fox jumps over the lazy dog", 0, 0, 0, 0);
                jpeg.SetAbsolutePosition(120f, 550f);
                document.Add(jpeg);
            }

            catch (Exception de)
            {
                Console.Error.WriteLine(de.Message);
            }

            // step 5: we close the document
            document.Close();

            Console.ReadLine();
        }
    }
}
